from device.utils.gpio import GPIO


def light_handler(gpio: str, target_power: int):
    light = GPIO(gpio)
    if target_power > 0:
        light.open()
    elif target_power == 0:
        light.close()

# 读取灯泡的状态的函数，每60秒自动读一次
def read_light(gpio: str):
    light = GPIO(gpio)
    return light.get_gpio_value()
